package com.edou.study.controller;

import jakarta.annotation.Resource;
import org.springframework.ai.chat.client.ChatClient;
import org.springframework.ai.chat.model.ChatModel;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class ChatClientControllerV2 {

    @Resource
    private ChatClient dashscopeChatClient;

    @Resource
    private ChatModel chatModel;


    @GetMapping("/chatclientv2/dochat")
    public String doChat(@RequestParam(name = "msg", defaultValue = "2加9等于几") String msg) {
        return dashscopeChatClient.prompt().user(msg).call().content();
    }

    @GetMapping("/chatclientv2/dochat2")
    public String doChat2(@RequestParam(name = "msg", defaultValue = "3加4等于几") String msg) {
        String result = chatModel.call(msg);
        System.out.println("ChatModel响应:" + result);
        return result;
    }
}
